import { Injectable } from '@angular/core';
import { CommHttpService } from '../../../core/comm.http.service';
import { HttpService } from '../../../core/http.service';
import { SERVERS_NAME } from '../../../config/config';
import { Observable } from 'rxjs';
import { Response } from '../../../core/domain/response';

@Injectable()
export class MenuService extends CommHttpService {

  protected preUrl = `${SERVERS_NAME.SECURITY_SERVER}sys/module/`;

  constructor(protected http: HttpService) {
    super(http);
  }

  /**
   * 获取菜单树
   * @param parentId 菜单树上级ID
   */
  pageQuery(): Observable<Response> {
    return this.http.post({}, this.preUrl + 'pageTree');
  }

  /**
   * 获取级联选择树
   */
  listTree(): Observable<Response> {
    return this.http.get({}, this.preUrl + 'listTree');
  }

  /**
   * 编辑查看
   * @param key 菜单树上级ID
   */
  editSee(key: string): Observable<Response> {
    return this.http.post({id: key}, this.preUrl + 'edit');
  }
}
